/* 
 * File:   image.h
 * Author: gustavo
 *
 * Created on May 30, 2011, 11:47 PM
 */

#ifndef IMAGE_H
#define	IMAGE_H

#include "../matrix/matrix.h"
#include "data_types/data_types.h"

#ifdef	__cplusplus
extern "C" {
#endif

#define _Image		image_get_interface()

	typedef enum _image_palette ImagePalette;
	typedef struct _image Image;
	typedef struct _image_interface ImageInterface;

	enum _image_palette {
		IMAGE_PALETTE_GRAY,
		IMAGE_PALETTE_RGB,
		IMAGE_PALETTE_YUV420p
	};

	struct _image {
		int width;
		int height;
		unsigned char * data;

		int bands;
		long int size;

		ImagePalette palette;

		struct {
			int (*get_pixel)(Image * img, int x, int y);
			void (*set_pixel)(Image * img, int x, int y, int px);
		} methods;
	};
	
	
	// test of data structure
	struct _img {
		Matrix matrix;
		int bands;
		
		ImagePalette palette;		
	};

	Image * image_new(int width, int height, ImagePalette palette);
	void image_delete(Image * img);
	int image_get_pixel(Image * img, int x, int y);
	void image_set_pixel(Image * img, int x, int y, int px);
	
	void image_gray2mat(const Image * Gray, Matrix ** Mat);
	void image_mat2gray(const Matrix * Mat, Image ** Gray);
	
	void image_rgb2gray(const Image * RGB, Image ** Gray);
	void image_gray2rgb(const Image * Gray, Image ** RGB);
	
	void image_assign_data(Image * img, unsigned char * data, int width, int height, ImagePalette palette);

#ifdef	__cplusplus
}
#endif

#endif	/* IMAGE_H */

